package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FinancialKeyword;
import com.ruoyi.system.service.IFinancialKeywordService;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * keywordController
 * 
 * @author ruoyi
 * @date 2024-12-07
 */
@RestController
@RequestMapping("/system/keyword")
public class FinancialKeywordController extends BaseController
{
    @Autowired
    private IFinancialKeywordService financialKeywordService;

    /**
     * 查询keyword列表
     */
    @PreAuthorize("@ss.hasPermi('system:keyword:list')")
    @GetMapping("/list")
    public AjaxResult list(FinancialKeyword financialKeyword)
    {
        List<FinancialKeyword> list = financialKeywordService.selectFinancialKeywordList(financialKeyword);
        return success(list);
    }

    /**
     * 导出keyword列表
     */
    @PreAuthorize("@ss.hasPermi('system:keyword:export')")
    @Log(title = "keyword", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FinancialKeyword financialKeyword)
    {
        List<FinancialKeyword> list = financialKeywordService.selectFinancialKeywordList(financialKeyword);
        ExcelUtil<FinancialKeyword> util = new ExcelUtil<FinancialKeyword>(FinancialKeyword.class);
        util.exportExcel(response, list, "keyword数据");
    }

    /**
     * 获取keyword详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:keyword:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(financialKeywordService.selectFinancialKeywordById(id));
    }

    /**
     * 新增keyword
     */
    @PreAuthorize("@ss.hasPermi('system:keyword:add')")
    @Log(title = "keyword", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FinancialKeyword financialKeyword)
    {
        return toAjax(financialKeywordService.insertFinancialKeyword(financialKeyword));
    }

    /**
     * 修改keyword
     */
    @PreAuthorize("@ss.hasPermi('system:keyword:edit')")
    @Log(title = "keyword", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FinancialKeyword financialKeyword)
    {
        return toAjax(financialKeywordService.updateFinancialKeyword(financialKeyword));
    }

    /**
     * 删除keyword
     */
    @PreAuthorize("@ss.hasPermi('system:keyword:remove')")
    @Log(title = "keyword", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(financialKeywordService.deleteFinancialKeywordByIds(ids));
    }
}
